﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScheduleMaker.DB.Domain;
using NHibernate;
using NHibernate.Criterion;
using NHibernate.Transform;

namespace ScheduleMaker.DB
{
    public class TeacherDAOUniversity : AbstractDAO<TeacherUniversity>
    {
        public TeacherUniversity findByLogin(string login)
        {
            createSession();
            ICriteria criteria = session.CreateCriteria(typeof(TeacherUniversity))
                .Add(Restrictions.Eq("Login", login)).SetResultTransformer(new DistinctRootEntityResultTransformer());
            IList<TeacherUniversity> users = criteria.List<TeacherUniversity>();
            closeSession();
            return users.ElementAt<TeacherUniversity>(0);
        }
    }
}
